package com.bj58.migrate.task;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.bj58.migrate.ConditionBuilder;
import com.bj58.migrate.condition.CycleCondtion;
import com.bj58.migrate.condition.impl.CateCondition;
import com.bj58.migrate.condition.impl.LocalCondition;
import com.bj58.migrate.condition.impl.PayWayCondition;
import com.bj58.migrate.condition.impl.PostdateCondition;
import com.bj58.migrate.condition.impl.StateCondition;
import com.bj58.migrate.helper.DateHelper;

public class JZTask{

	private static ConditionBuilder builder;

	/**
	 * @param args
	 */
	public static void main( String[] args ){

		com.bj58.spat.scf.client.SCFInit.init( "/opt/apps/app/avgsalary/conf/scf.config" );

		buildJZCondition();

		// buildCondition();

		new JZTask().test();
	}

	public void test(){

		String formatFileName = DateHelper.convertDatetoString( "yyyyMM", new Date() );
		// 文件读取方式、薪资处理类、文件夹名称、兼职薪资结算方式、启用新文件夹名称（sr读取方式可用）
		String[] args = { "sr", "avg-jz", formatFileName, "1", "jianzhi" };

		Task task = new Task( args );
		task.run( args );
	}

	protected static void buildJZCondition(){

		List< CycleCondtion > list = new ArrayList< CycleCondtion >();

		// String nowDate = DateHelper.convertDatetoString( "yyyyMM", new Date() );
		list.add( new CateCondition( 1, 13941 ) );
		// list.add( new PostdateCondition( nowDate + "01", nowDate + "31", true ) );
		list.add( new PostdateCondition( "20150401", "20150731", true ) );
		list.add( new StateCondition() );
		list.add( new PayWayCondition() );
		list.add( new LocalCondition() );

		builder = new ConditionBuilder( list );

		try{
			builder.separation( "jianzhi", 1 );
		}
		catch( Exception e ){
			e.printStackTrace();
		}
	}

	protected static void buildCondition(){

		List< CycleCondtion > list = new ArrayList< CycleCondtion >();

		String nowDate = DateHelper.convertDatetoString( "yyyyMM", new Date() );
		list.add( new CateCondition() );
		list.add( new PostdateCondition( nowDate + "01", nowDate + "31", true ) );
		list.add( new StateCondition() );
		list.add( new LocalCondition() );

		builder = new ConditionBuilder( list );
	}

}
